<?php
using("Utils_ReflectionFacade");

class Tests_Utils_ReflectionFacade extends UnitTestCase {
	
	private $_class1 = "Utils_HashMap";
	private $_method1 = "put";
	private $_args1 = array();
	
	private $_class2 = "Util_HashMap";
	private $_method2 = "hello";
	private $_args2 = array("bar", "foo");
	
	public function testCreate() {
		$map = Utils_ReflectionFacade::getInstance($this->_class1, $this->_args1);
		$this->assertTrue(is_a($map, $this->_class1));
	}
	
	public function testCreateFail() {
		try {
			$map = Utils_ReflectionFacade::getInstance($this->_class2, $this->_args1);
			$this->fail();
		} catch (Utils_Exceptions_Reflection $e) {
			$this->pass();
		}
		
		try {
			$map = Utils_ReflectionFacade::getInstance($this->_class1, $this->_args2);
			$this->fail();
		} catch (Utils_Exceptions_Reflection $e) {
			$this->pass();
		}
	}
	
	public function testInvoke() {
		$map = Utils_ReflectionFacade::getInstance($this->_class1, $this->_args1);
		try {
			Utils_ReflectionFacade::invokeArgs($map, $this->_method1, $this->_args2);
			$this->pass();
		} catch (Utils_Exceptions_Reflection $e) {
			$this->fail();
		}
	}
	
	public function testInvokeFail() {
		$map = Utils_ReflectionFacade::getInstance($this->_class1, $this->_args1);
		try {
			Utils_ReflectionFacade::invokeArgs($map, $this->_method1, $this->_args1);
			$this->fail();
		} catch (Utils_Exceptions_Reflection $e) {
			$this->pass();
		}
		
		try {
			Utils_ReflectionFacade::invokeArgs($map, $this->_method2, $this->_args2);
			$this->fail();
		} catch (Utils_Exceptions_Reflection $e) {
			$this->pass();
		}
	}
}
?>